package com.check.checksamejourney.mapper;

import com.check.checksamejourney.bean.Subscribe;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface SubscribeMapper {

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into subscribe(user_id,wxmsg_template_id,date,type,site,state,create_time,update_time) " +
            "values(#{userId},#{wxmsgTemplateId},#{date},#{type},#{site},#{state},now(),now())")
    int insertSubscribe(Subscribe subscribe);

    @Update("update subscribe set date = #{date}, type = #{type}, site = #{site}, state = #{state}, update_time = now() " +
            "where id = #{id}")
    int updateSubscribe(Subscribe subscribe);

    @Select("select * from subscribe where is_deleted = 0 and user_id = #{userId}")
    List<Subscribe> getSubscribesByUserId(Long userId);

}
